import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import router from './router'
import { VueQueryPlugin, type VueQueryPluginOptions } from '@tanstack/vue-query'
// 导入自定义插件
import { CustomPlugin, createSimplePlugin, createTypedPlugin } from './plugins/CustomPlugin'
import './modules/event-global'

const VueQueryPluginOptinos: VueQueryPluginOptions = {
    queryClientConfig: {
        defaultOptions: {
            queries: {
                staleTime: 1000 * 30,  // 30秒内数据不重新请求
                refetchOnWindowFocus: false,  // 窗口聚焦不重新请求
            }
        }
    }
}

const app = createApp(App)
app.use(router)
app.use(VueQueryPlugin, VueQueryPluginOptinos)

// 使用自定义插件
app.use(CustomPlugin, {
  prefix: '[YumoPlugin]',
  globalMessage: '欢迎使用羽沫自定义插件！'
})

// 使用函数式插件
app.use(createSimplePlugin('来自简单插件的问候'))

// 使用类型化插件
app.use(createTypedPlugin({
  apiUrl: 'https://api.example.com',
  timeout: 5000,
  retries: 3,
  debug: true
}))

app.mount('#app')